# Contributor: Fernando Casas Schossow <casasfernando@outlook.com>
# Maintainer: Fernando Casas Schossow <casasfernando@outlook.com>
pkgname=ocaml-curses
_pkgname=curses
pkgver=1.0.10
pkgrel=0
pkgdesc="OCaml bindings for ncurses"
url="https://github.com/mbacarella/curses"
arch="all !riscv64" # restricted by ocaml
license="LGPL-2.1"
depends="ocaml-runtime"
depends_dev="$pkgname=$pkgver-r$pkgrel"
makedepends="dune dune-configurator-dev ncurses-dev ocaml ocaml-csexp-dev"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.bz2::https://github.com/mbacarella/curses/releases/download/$pkgver/curses-$pkgver.tbz"
builddir="$srcdir/$_pkgname-$pkgver"

# 32-bit archs
case "$CARCH" in
	arm*|x86) options="$options textrels" ;;
esac

build() {
	export OCAMLPATH=/usr/lib/ocaml
	dune build --root . @install --no-buffer --verbose
}

check() {
	dune runtest --no-buffer --verbose
}

package() {
	dune install \
		--destdir="$pkgdir" \
		--prefix=/usr \
		--libdir=/usr/lib/ocaml

	rm -Rf "$pkgdir"/usr/doc
}

dev() {
	default_dev

	cd "$pkgdir"

	local path; for path in $(find usr/lib/ocaml \( \
			-name '*.cmt' -o \
			-name '*.cmti' -o \
			-name '*.cmx' -o \
			-name '*.cmxa' -o \
			-name '*.ml' -o \
			-name '*.mli' \
		\))
	do
		amove "$path"
	done
}

sha512sums="
158626f3fd6931f30482a47ab149990ff49334c8c0dc966eb07d92f22e87faaab3fd48ed7788bbc5a77f82cb6163520588ce55ab53456bca22994f147c7e00c5  ocaml-curses-1.0.10.tar.bz2
"
